# -*- coding: utf-8 -*-
from pysnmp.hlapi import *
 
deviceIP = "192.168.33.10"
snmpv2Community = "public"
 
# ----------------------------------------------------------------
def getDeviceName(deviceIP, snmpCommunity):   
    deviceNameOID = ".1.3.6.1.2.1.25.1"
    errorIndication, errorStatus, errorIndex, varBinds = next(
        getCmd(SnmpEngine(),
               CommunityData(snmpCommunity),
               UdpTransportTarget((deviceIP, 161)),
               ContextData(),
               ObjectType(ObjectIdentity(deviceNameOID))
               )
    )
 
    if errorIndication:
        print(errorIndication)
    elif errorStatus:
        print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
    else:
        for varBind in varBinds:
            print(' = '.join([x.prettyPrint() for x in varBind]))

def main():
    getDeviceName(deviceIP, snmpv2Community)
 
 
if __name__ == '__main__':
  main()
